<template>
  <view class="inventory_wrap template-page ">
    <view class="content">
      <view id="view_warper" ref="pdfDom" :class="{ pdf_download: pdfDownload }"
        class="flex_1 m-l-20 b-l p-l-20 margin_left_10 view_warper left-page" style="flex:1;padding-bottom: 240rpx;">
        <view v-if="archivesData.archivesType == ARCHIVES_TYPE.SLIGHT">
          <FireAccidentSimpleInvestigation v-model="formData" />
        </view>
        <view v-else-if="archivesData.archivesType == ARCHIVES_TYPE.SIMPLE">
          <MinorFire v-model:formData="formData" />
        </view>
        <view v-else>
          <MinorFire v-model:formData="formData" />
        </view>
      </view>
    </view>
    <FooterBtn class="footer-btn" :pdfDownload="pdfDownload" @submit="submitForm" @cancel="handleCancel" />
    <DownloadBtn class="download-btn" :pdfDownload="pdfDownload"
      :title="archivesData.archivesType == '2' ? '轻微火灾登记书' : '火灾事故简易调查认定书'" :formData="formData"
      :moduleName="currentModule.moduleName" @saveData="submitFormBackBefore" />
  </view>
</template>

<script>
import DataFlow from '@/pagesH5/mixins/DataFlow.js'
import eventBus from '../../common/eventBus'
import DownloadBtn from '@/pagesH5/components/DownloadBtn'
import FooterBtn from '@/pagesH5/components/FooterBtn'
import MinorFire from './components/MinorFire.vue'
import FireAccidentSimpleInvestigation from './components/FireAccidentSimpleInvestigation.vue'
import { ARCHIVES_TYPE } from '@/const/archives/index.js'
export default {
  mixins: [DataFlow],
  components: { MinorFire, FireAccidentSimpleInvestigation, DownloadBtn, FooterBtn },
  data() {
    return { ARCHIVES_TYPE };
  },
  computed: {},
  onShow() {
    eventBus.$on('get-sign-event', (args, obj, sign) => {
      console.log('sign event args: ', args)
      console.log('sign event obj: ', obj)
      console.log('sign event sign: ', sign)
      this.$set(this[obj], sign, args)
      let time = this.parseTime(new Date(), '{y}年{m}月{d}日')
      if (sign === 'preparer') this.$set(this.formData, 'signTime', `${this.parseTime(new Date(), '{y}-{m}-{d} {h}:{i}:{s}')}`)
      console.log('this.formData: ', this.formData)
    })
  },
  methods: {
    initForm() {
      let initForm = {
        title: `${this.$u.timeFormat(new Date(), 'yyyymmddhhMM')}`,
        fireTime: '',
        fireAddress: [],
        fireCompany: "",
        contactor: "",
        contactorPhone: "",
        siteType: "",
        fireItem: "",
        burnedArea: "",
        economicLoss: "",
        insurance: "",
        preparer: "",
        statisticstor: "",
        statisticsTime: '',
        remark: "",
        signTime: "",
        investigatorsTime: ""
      };
      return initForm
    },
    async submitFormBefore() {
      console.log(this.formData);
    }
  }
};
</script>

<style lang="scss">
.map-input {
  display: flex;
  align-items: center;
  padding-left: 10px;
  box-sizing: border-box;
  height: 42px;
  color: #999;
  font-size: 14px;

  &.has-value {
    color: #606266;
  }
}

.view_warper {
  // font-family: FZST;
  font-size: 17px;
  color: #000;
  padding: 15px 30px 70px;
  position: relative;
}
</style>
